<?php

namespace App\Store\Validate\Financial\Statements;

use App\Common\Validate\BaseValidate;

/**
 * 验证器
 */
class Moneylog extends BaseValidate
{
    //验证规则
    protected $rule = [];
    //自定义验证信息
    protected $message = [];

    public function __construct($doaction = 'add')
    {
        if ($doaction == 'add') {
            $this->rule = [
                'type'=>'required|in:1,2,3',
                'inout_type'=>'required|in:1,2',
//                'receipt_type'=>'required|in:0,1,2,3',
                'log_date'=>'required|date',
                // 'pay_type_id'=>'required|integer',
                'receipt_no'=>'required',
                'subject_id'=>'required|integer|gte:-5',
                'income_money'=>'required|integer|gte:0',
                'expenditure_money'=>'required|integer|gte:0',
                'residue_money'=>'required|integer',
            ];
            $this->message = [
                'type.required' => '参数错误',
                'type.in' => '参数错误',
                'inout_type.required' => '收付类型未选择',
                'inout_type.in' => '收付类型参数错误',
//                'receipt_type.required' => '收付类型未选择',
                'receipt_type.in' => '收付类型参数错误',
                'log_date.required' => '日期不能为空',
                'log_date.in' => '日期格式错误',
                // 'pay_type_id.required' => '收款方式未选择',
                // 'pay_type_id.integer' => '收款方式参数错误',
                // 'pay_type_id.gt' => '收款方式参数错误',
                'receipt_no.required' => '单据号不能为空',
                'subject_id.required' => '科目未选择',
                'subject_id.integer' => '科目参数错误',
                'subject_id.gt' => '科目参数错误',


                'income_money.required' => '收入金额不能为空',
                'income_money.integer' => '收入金额需大于等于0',
                'income_money.gte' => '收入金额需大于等于0',

                'expenditure_money.required' => '支出金额不能为空',
                'expenditure_money.integer' => '支出金额需大于等于0',
                'expenditure_money.gte' => '支出金额需大于等于0',

                'residue_money.required' => '余额不能为空',
                'residue_money.integer' => '余额需为数字格式',
                // 'residue_money.gte' => '余额需大于等于0',

            ];
        }elseif($doaction=='edit') {
            $this->rule = [
                'id' => 'required|integer|gt:0',
                'type'=>'required|in:1,2,3',
                'inout_type'=>'required|in:1,2',
//                'receipt_type'=>'required|in:0,1,2,3',
                'log_date'=>'required|date',
                // 'pay_type_id'=>'required|integer',
                'receipt_no'=>'required',
                'subject_id'=>'required|integer|gte:-5',
                'income_money'=>'required|integer|gte:0',
                'expenditure_money'=>'required|integer|gte:0',
                'residue_money'=>'required|integer',
            ];
            $this->message = [
                'id.required' => '账户参数错误',
                'id.integer' => '账户参数错误',
                'id.gt' => '账户参数错误',
                'type.required' => '参数错误',
                'type.in' => '参数错误',
                'inout_type.required' => '收付类型未选择',
                'inout_type.in' => '收付类型参数错误',
//                'receipt_type.required' => '收付类型未选择',
                'receipt_type.in' => '收付类型参数错误',
                'log_date.required' => '日期不能为空',
                'log_date.in' => '日期格式错误',
                // 'pay_type_id.required' => '收款方式未选择',
                // 'pay_type_id.integer' => '收款方式参数错误',
                // 'pay_type_id.gt' => '收款方式参数错误',
                'receipt_no.required' => '单据号不能为空',
                'subject_id.required' => '科目未选择',
                'subject_id.integer' => '科目参数错误',
                'subject_id.gt' => '科目参数错误',


                'income_money.required' => '收入金额不能为空',
                'income_money.integer' => '收入金额需大于等于0',
                'income_money.gte' => '收入金额需大于等于0',

                'expenditure_money.required' => '支出金额不能为空',
                'expenditure_money.integer' => '支出金额需大于等于0',
                'expenditure_money.gte' => '支出金额需大于等于0',

                'residue_money.required' => '余额不能为空',
                'residue_money.integer' => '余额需为数字格式',
                // 'residue_money.gte' => '余额需大于等于0',
            ];
        }
    }
}
